<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>同花顺速递</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">	
			p {margin:0px;}					
			ul {margin:5px;}			
			h4 {margin:0px}	
			.fixedBox{
				border: 1px solid #555555;				
				
			}
			.fixedBox::-webkit-scrollbar {
				width: 10px;     
				height: 10px;				
			}	
			#f1{
				color: #FFD700;
				margin-left:-5px;
			}			
			#f2{
				color: #FFFFE0;
			}
			#f3{
				color: #00FFFF;
				margin-left:-5px;
			}
			#f4{
				color: #7FFF00;				
				margin-left:-5px;				
			}				
		</style>		
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script>
			window.onload = function() {
			getSource();
			changeStyle();
			}
						
			
			function changeStyle() {
				var obj = document.getElementById("towrite");				
				obj.style.left = "0px"; 				
				obj.style.width = "98%";	
				//obj.style.height = "620px";		
				obj.style.fontSize ="12px";					
			}
			
			
			$(function() {
				setInterval(function() {
					getSource();
				},
				500);
			})
			
			var gpdm = "";
			var gpmc = "";
			var dm ="";			
			function getSource() {								
				var u = decodeURI(window.location.href);								
				if(u.indexOf("##") > -1){
					var gp = u.split('##');				
					dm = gp[1];
					gpmc = gp[2];															
				}else{
					dm = "600000";
					gpmc = "浦发银行";					
				}
				if(dm != gpdm){
					gpdm = dm;
					var sc = "";
					if(gpdm.substr(0 , 1) == "6"){				
						sc = "17";
					}else{					
						sc = "33";
					}			
					var url = "https://eq.10jqka.com.cn/stockCourier/api/courier/eventData/" + sc + "/" + gpdm + ".txt";												
					var res = [];
					$.ajax({
						type: "get",
						url: url,
						dataType: "json",
						async : false,
						cache:false,
						timeout:3000,					
						success: function(data) {
							//alert(JSON.stringify(data))						
							//document.write(JSON.stringify(data));
							res = data.data.events;
							function up(a,b){
								var aa = a.ctime;
								var bb = b.ctime;					
								if(a.catename == "涨停分析"){
									aa = 0;
								}
								if(b.catename == "涨停分析"){
									bb = 0;
								}					
								return aa - bb					
							}
							res.sort(up);
						}
					});
					//document.write(JSON.stringify(res));			
					div = document.getElementById('towrite');
					div.innerHTML = "<font size='3' style=color:#FFFF00;>同花顺速递：<font size='2' color=#fff>&nbsp;&nbsp;&nbsp;&nbsp;" + gpdm + "&nbsp;&nbsp;" + gpmc + "</font></font>";
					
					var data = 	JSON.stringify(res);										
					var transform_aa1 = [           
					{"tag":"p", children:function(){return(json2html.transform(this, transform_bb1));}}
					];
					
					var transform_bb1=												
					{"tag":"ul style=color:#FFA500;", children:[									
					//{"tag": "li style=color:#00FFFF;", "html":"${catename}： ${date}"},
					{"tag": "li style=color:#00FFFF;", "html":function(){
						if(this.catename == "龙虎榜"){							
							var url = "http://www.treeid/dlghttp://page.tdx.com.cn:7615/site/kggx/tk_ygzl_lhb.html?info=xxxxxx&amp;pageId=dpyd&amp;color=0&amp;bkcolor=000000"
							var lhb = "<a href='" + url + "' style='color:#FF00FF;'>" + this.catename + "：" + this.date + "</a>";							
							return(lhb);
						}else{
							return(this.catename + "：" + this.date);
						}
					
					}},
					{"tag": "p", "html": function(){
						if(this.catename == "涨停分析"){
							return(this.title.replace("涨停分析:","<p style=color:#F5FFFA;>").replace("｜","：</p>"));
						}else{
							return(this.content);
						}
					}},					
					{"tag": "p style=color:#FFF5EE;", "html":"${desc}"}, 						
					]};
					
					var html1 = json2html.transform(data, transform_aa1);	
					
					//简易F10
					var url2 = "http://basic.10jqka.com.cn/api/stockph/simple/f10/" + gpdm;												
					var res2 = [];
					$.ajax({
						type: "get",
						url: url2,
						dataType: "json",
						async : false,
						cache:false,
						timeout:3000,					
						success: function(data) {
							//alert(JSON.stringify(data))						
							//document.write(JSON.stringify(data));
							res2 = data.data;
							
						}
					});
										
					
					div.innerHTML += "<p style='margin-left:10px;'><a href='javascript:void(0)' style='color:#7FFF00;font-size:14px;' onclick='update()'>简易F10：</a></p>";					
					
					var newdiv = document.createElement('div');
					newdiv.id = "jyf10";
					newdiv.style.display = "block";  //默认显示block；不显示：none;
					newdiv.style.width= "96%";	
					newdiv.style.marginLeft= "5px";
					newdiv.style.border= "2px solid #A9A9A9";	
					div.appendChild(newdiv);
					
					var html2 = "";
					html2 += "<p><span id=f1>主营业务：</span><span id=f2>" + res2.mainproduct.info + "</span></p>";
					html2 += "<p style=margin-top:3px;><span id=f1>所属概念：</span><span id=f2>" + res2.blocks.info + "</span></p>";
					html2 += "<p style=margin-top:3px;><span id=f1>行业地域：</span><span id=f2>" + res2.industry.tip + "（" + res2.area.info + "）" + "</span></p>";
					var jjlx = "";
					if(res2.restrictedtype.info != ""){
						jjlx = "（" + res2.restrictedtype.info + "）";
					}
					html2 += "<p style=margin-top:3px;><span id=f3>最新解禁：</span><span id=f2>" + res2.restricted.info + jjlx + "</span></p>";
					
					var jjsl = "";
					if(res2.restrictednum.info != "--"){
						jjsl = "<p style=margin-top:3px;><span id=f3>解禁数量：</span><span id=f2>" + res2.restrictednum.info+ "（占总股本比：" + res2.restrictedpercent.info + "）</span></p>";
					}
					html2 += jjsl;
					
					var zzy = "";
					if(res2.pledge.info != "--" && res2.pledgepercent.info != "--" && res2.pledge.info != "0.00股"){
						zzy = "<p style=margin-top:3px;><span id=f1>总 质 押：</span><span id=f2>" + res2.pledge.info+ "（占总股本比：" + res2.pledgepercent.info + "）</span></p>";
					}
					html2 += zzy;
										
					if(res2.reducerate.info != "--"){
						var jcjh = "<p style=margin-top:3px;><span id=f4>减持计划：</span><span id=f2>" + res2.reduceplan.info+ "（占总股本比：" + res2.reducerate.info + "）</span></p>";						
						html2 += jcjh;
						
						var jcr = "<p style=margin-top:3px;><span id=f4>减持人：</span><span id=f2>" + res2.reduceholder.info+ "（最新计划：" + res2.newreducedate.info + "）</span></p>";						
						html2 += jcr;
						
						var hjjc = "<p style=margin-top:3px;><span id=f4>合计减持：</span><span id=f2>" + res2.reducetotal.info+ "（" + res2.reducestart.info +" - " + res2.reduceend.info +"）</span></p>";						
						html2 += hjjc;
					}
					newdiv.innerHTML = html2;
					
					div.innerHTML += html1;
					div.scrollTop = 0; //回到顶部
				}
			}
			
			function update() {	
					var div = document.getElementById("jyf10");					
					if(div.style.display == "block"){
						div.style.display = "none";
					}else{
						div.style.display = "block";
					}					 												
			}			
		</script>
	</head>
	<body>
		<div id="towrite" class="fixedBox"></div>		
	</body>
</html>